var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
(function (factory) {
    if (typeof module === "object" && typeof module.exports === "object") {
        var v = factory(require, exports);
        if (v !== undefined) module.exports = v;
    }
    else if (typeof define === "function" && define.amd) {
        define(["require", "exports", "koa-router", "../lib/TileTool/TileUtil4326", "../lib/TileTool/TileUtil3857"], factory);
    }
})(function (require, exports) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    const koa_router_1 = __importDefault(require("koa-router"));
    const TileUtil4326_1 = __importDefault(require("../lib/TileTool/TileUtil4326"));
    const TileUtil3857_1 = __importDefault(require("../lib/TileTool/TileUtil3857"));
    const TileRoutes = new koa_router_1.default({ prefix: '/TileServer' });
    const tileUtil3857 = new TileUtil3857_1.default();
    const tileUtil4326 = new TileUtil4326_1.default();
    TileRoutes
        .all('/getTilesByGeoJson', async (ctx) => {
        ctx.set('Content-Type', 'application/json;charset=utf-8');
        const { token, tileSchema, level, dataSourceName, dataSourceToken, targetDirectory, geoJson } = ctx.request.body;
        const tileUtil = tileSchema === 'layer-xyz-3857' ? tileUtil3857 : tileUtil4326;
        const tileList = tileUtil.getTilesByGeoJson(geoJson, level);
        ctx.body = JSON.stringify({
            code: 200,
            message: '瓦片分析成功',
            data: tileList
        });
        ctx.status = 200;
    });
    exports.default = TileRoutes;
});
